noinst_PROGRAMS += \
	Programs/ImageDiff

if ENABLE_WEBKIT1
noinst_PROGRAMS += \
	Programs/DumpRenderTree \
	Programs/GtkLauncher
endif

# GtkLauncher
Programs_GtkLauncher_CPPFLAGS = \
	-I$(srcdir)/Source/WebKit/gtk \
	-I$(srcdir)/Source/WebCore/platform/network/soup/cache/ \
	-I$(top_builddir)/Source/WebKit/gtk \
	-I$(top_builddir)/DerivedSources \
	-DWEBKIT_EXEC_PATH=\"${shell pwd}/$(top_builddir)/Programs/\" \
	$(global_cppflags) \
	$(javascriptcore_cppflags)

Programs_GtkLauncher_SOURCES = \
	Tools/GtkLauncher/LauncherInspectorWindow.c \
	Tools/GtkLauncher/LauncherInspectorWindow.h \
	Tools/GtkLauncher/main.c

Programs_GtkLauncher_CFLAGS = \
	-ansi \
	-fno-strict-aliasing \
	$(global_cflags) \
	$(FREETYPE_CFLAGS) \
	$(GTK_CFLAGS) \
	$(LIBSOUP_CFLAGS) \
	$(GSTREAMER_CFLAGS)

Programs_GtkLauncher_LDADD = \
	libwebkitgtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
	libjavascriptcoregtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
	$(FREETYPE_LIBS) \
	$(GTK_LIBS) \
	$(GLIB_LIBS) \
	$(LIBSOUP_LIBS) \
	$(WINMM_LIBS) \
	$(GSTREAMER_LIBS)

Programs_GtkLauncher_LDFLAGS = \
	-no-fast-install \
	-no-install

# libWebCoreInternals
# We must split off the window.internals implementation into a separate
# convenience library because it requires a different include path order
# to prefer the WebCore config.h over the DumpRenderTree config.h
noinst_LTLIBRARIES += libWebCoreInternals.la
libWebCoreInternals_la_SOURCES = \
	Source/WebCore/bindings/js/JSDOMWrapper.cpp \
	Source/WebCore/bindings/js/JSDOMWrapper.h \
	Source/WebCore/testing/MallocStatistics.h \
	Source/WebCore/testing/MemoryInfo.h \
	Source/WebCore/testing/Internals.cpp \
	Source/WebCore/testing/Internals.h \
	Source/WebCore/testing/InternalSettings.cpp \
	Source/WebCore/testing/InternalSettings.h \
	Source/WebCore/testing/TypeConversions.h \
	Source/WebCore/testing/js/WebCoreTestSupport.cpp \
	Source/WebCore/testing/js/WebCoreTestSupport.h

libwebcoreinternals_built_sources += \
	DerivedSources/WebCore/InternalSettingsGenerated.cpp \
	DerivedSources/WebCore/InternalSettingsGenerated.h   \
	DerivedSources/WebCore/JSMallocStatistics.cpp \
	DerivedSources/WebCore/JSMallocStatistics.h   \
	DerivedSources/WebCore/JSMemoryInfo.cpp \
	DerivedSources/WebCore/JSMemoryInfo.h \
	DerivedSources/WebCore/JSInternals.cpp \
	DerivedSources/WebCore/JSInternals.h   \
	DerivedSources/WebCore/JSInternalSettings.cpp \
	DerivedSources/WebCore/JSInternalSettings.h   \
	DerivedSources/WebCore/JSInternalSettingsGenerated.cpp \
	DerivedSources/WebCore/JSInternalSettingsGenerated.h \
	DerivedSources/WebCore/JSTypeConversions.cpp \
	DerivedSources/WebCore/JSTypeConversions.h

nodist_libWebCoreInternals_la_SOURCES = $(libwebcoreinternals_built_sources)
BUILT_SOURCES += $(libwebcoreinternals_built_sources)

libWebCoreInternals_la_CPPFLAGS = \
	$(global_cppflags) \
	$(platform_cppflags) \
	$(platformgtk_cppflags) \
	$(webcore_cppflags) \
	$(webcoregtk_cppflags) \
	$(javascriptcore_cppflags) \
	$(CAIRO_CFLAGS) \
	$(FREETYPE_CFLAGS) \
	$(LIBSOUP_CFLAGS) \
	$(PANGO_CFLAGS) \
	-I$(top_builddir)/DerivedSources \
	-I$(top_builddir)/DerivedSources/WebCore

libWebCoreInternals_la_CXXFLAGS = \
	$(global_cxxflags) \
	$(libWebCoreInternals_la_CFLAGS)

libWebCoreInternals_la_CFLAGS = \
	-fno-strict-aliasing \
	$(javascriptcore_cflags)

# DumpRenderTree
Programs_DumpRenderTree_CPPFLAGS = \
	$(global_cppflags) \
	-DTOP_LEVEL_DIR=\"${shell pwd}/${srcdir}\" \
	-I$(srcdir)/Tools/DumpRenderTree \
	-I$(srcdir)/Tools/DumpRenderTree/atk \
	-I$(srcdir)/Tools/DumpRenderTree/cairo \
	-I$(srcdir)/Tools/DumpRenderTree/gtk \
	-I$(srcdir)/Source/WebKit/gtk \
	-I$(srcdir)/Source/WebCore/platform/gtk \
	-I$(srcdir)/Source/WebCore/testing/js \
	-I$(top_builddir)/DerivedSources \
	-I$(top_builddir)/Source/WebKit/gtk \
	$(javascriptcore_cppflags) \
	$(platform_cppflags) \
	$(platformgtk_cppflags) \
	$(webcore_cppflags)

if TARGET_X11
Programs_DumpRenderTree_CPPFLAGS += \
	-DTEST_PLUGIN_DIR=\"${shell pwd}/${top_builddir}/TestNetscapePlugin/.libs\" \
	-DFONTS_CONF_DIR=\"${shell pwd}/${srcdir}/Tools/DumpRenderTree/gtk/fonts\"
endif

Programs_DumpRenderTree_SOURCES = \
	Source/WebCore/platform/gtk/GtkVersioning.c \
	Tools/DumpRenderTree/DumpRenderTree.h \
	Tools/DumpRenderTree/DumpRenderTreeCommon.cpp \
	Tools/DumpRenderTree/DumpRenderTreePrefix.h \
	Tools/DumpRenderTree/AccessibilityController.cpp \
	Tools/DumpRenderTree/AccessibilityController.h \
	Tools/DumpRenderTree/AccessibilityTextMarker.cpp \
	Tools/DumpRenderTree/AccessibilityTextMarker.h \
	Tools/DumpRenderTree/AccessibilityUIElement.cpp \
	Tools/DumpRenderTree/AccessibilityUIElement.h \
	Tools/DumpRenderTree/CyclicRedundancyCheck.cpp \
	Tools/DumpRenderTree/CyclicRedundancyCheck.h \
	Tools/DumpRenderTree/GCController.cpp \
	Tools/DumpRenderTree/GCController.h \
	Tools/DumpRenderTree/JavaScriptThreading.h \
	Tools/DumpRenderTree/TestRunner.cpp \
	Tools/DumpRenderTree/TestRunner.h \
	Tools/DumpRenderTree/PixelDumpSupport.cpp \
	Tools/DumpRenderTree/PixelDumpSupport.h \
	Tools/DumpRenderTree/WorkQueue.cpp \
	Tools/DumpRenderTree/WorkQueue.h \
	Tools/DumpRenderTree/WorkQueueItem.h \
	Tools/DumpRenderTree/config.h \
	Tools/DumpRenderTree/atk/AccessibilityCallbacks.h \
	Tools/DumpRenderTree/atk/AccessibilityCallbacksAtk.cpp \
	Tools/DumpRenderTree/atk/AccessibilityControllerAtk.cpp \
	Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp \
	Tools/DumpRenderTree/cairo/PixelDumpSupportCairo.cpp \
	Tools/DumpRenderTree/cairo/PixelDumpSupportCairo.h \
	Tools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp \
	Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp \
	Tools/DumpRenderTree/gtk/DumpRenderTree.cpp \
	Tools/DumpRenderTree/gtk/DumpRenderTreeGtk.h \
	Tools/DumpRenderTree/gtk/EditingCallbacks.h \
	Tools/DumpRenderTree/gtk/EditingCallbacks.cpp \
	Tools/DumpRenderTree/gtk/EventSender.h \
	Tools/DumpRenderTree/gtk/EventSender.cpp \
	Tools/DumpRenderTree/gtk/GCControllerGtk.cpp \
	Tools/DumpRenderTree/gtk/TestRunnerGtk.cpp \
	Tools/DumpRenderTree/gtk/PixelDumpSupportGtk.cpp \
	Tools/DumpRenderTree/gtk/SelfScrollingWebKitWebView.cpp \
	Tools/DumpRenderTree/gtk/SelfScrollingWebKitWebView.h \
	Tools/DumpRenderTree/gtk/TextInputController.h \
	Tools/DumpRenderTree/gtk/TextInputController.cpp \
	Tools/DumpRenderTree/gtk/WorkQueueItemGtk.cpp

Programs_DumpRenderTree_CXXFLAGS = \
	$(global_cxxflags) \
	$(Programs_DumpRenderTree_CFLAGS)

Programs_DumpRenderTree_CFLAGS = \
	-fno-strict-aliasing \
	$(global_cflags) \
	$(GLOBALDEPS_CFLAGS) \
	$(CAIRO_CFLAGS) \
	$(GTK_CFLAGS) \
	$(LIBSOUP_CFLAGS)

Programs_DumpRenderTree_LDADD = \
	libjavascriptcoregtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
	libwebkitgtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
	libPlatform.la \
	libPlatformGtk.la \
	libWebCorePlatform.la \
	libWebCoreModules.la \
	libWebCoreInternals.la \
	$(GLOBALDEPS_LIBS) \
	$(CAIRO_LIBS) \
	$(GTK_LIBS) \
	$(GLIB_LIBS) \
	$(LIBSOUP_LIBS) \
	$(FREETYPE_LIBS) \
	$(WINMM_LIBS) \
	$(XRENDER_LIBS) \
	$(XT_LIBS)

Programs_DumpRenderTree_LDFLAGS = \
	-no-fast-install \
	-no-install

# ImageDiff
Programs_ImageDiff_CPPFLAGS = $(global_cppflags)

Programs_ImageDiff_SOURCES = \
   Tools/ImageDiff/gtk/ImageDiff.cpp

Programs_ImageDiff_CXXFLAGS = \
   $(global_cxxflags) \
   $(global_cppflags) \
   $(Programs_ImageDiff_CFLAGS)

Programs_ImageDiff_CFLAGS = \
   -fno-strict-aliasing \
   $(global_cflags) \
   $(GLOBALDEPS_CFLAGS) \
   $(GTK_CFLAGS)

Programs_ImageDiff_LDADD = \
   $(GTK_LIBS)

Programs_ImageDiff_LDFLAGS = \
   -no-fast-install \
   -no-install

# clean target
CLEANFILES += \
	Programs/DumpRenderTree \
	Programs/GtkLauncher \
	Programs/ImageDiff

if TARGET_X11

# Build TestNetscapePlugin only for X11
# since we don't support plugins for non-X11 builds at the moment.
noinst_LTLIBRARIES += \
	TestNetscapePlugin/libtestnetscapeplugin.la

TestNetscapePlugin_libtestnetscapeplugin_la_CPPFLAGS = \
	-I$(srcdir)/Tools/DumpRenderTree \
	-I$(srcdir)/Source/WebCore \
	-I$(srcdir)/Source/WebCore/bridge \
	-I$(srcdir)/Source/WebCore/plugins \
	-I$(srcdir)/Tools/DumpRenderTree/TestNetscapePlugIn \
	-I$(srcdir)/Tools/DumpRenderTree/TestNetscapePlugIn/unix/ForwardingHeaders \
	$(global_cppflags) \
	$(javascriptcore_cppflags)

# For the Gtk port we want to use XP_UNIX both on X11 and Mac
if !TARGET_WIN32
TestNetscapePlugin_libtestnetscapeplugin_la_CPPFLAGS += -DXP_UNIX
endif

# Add MOZ_X11 only for X11 targets
if TARGET_X11
TestNetscapePlugin_libtestnetscapeplugin_la_CPPFLAGS += -DMOZ_X11
endif

TestNetscapePlugin_libtestnetscapeplugin_la_SOURCES = \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/DocumentOpenInDestroyStream.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSAfterRemovingPluginElement.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/FormValue.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/GetURLNotifyWithURLThatFailsToLoad.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/GetURLWithJavaScriptURL.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/GetURLWithJavaScriptURLDestroyingPlugin.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/GetUserAgentWithNullNPPFromNPPNew.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/LogNPPSetWindow.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/NPDeallocateCalledBeforeNPShutdown.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/NPPNewFails.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/NPPSetWindowCalledDuringDestruction.cpp \
    Tools/DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeCallsWithNullNPP.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeObjectFromDestroyedPlugin.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeRemoveProperty.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/NullNPPGetValuePointer.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/PassDifferentNPPStruct.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableNPObjectInvokeDefault.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/PrivateBrowsing.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/ToStringAndValueOfObject.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/Tests/x11/CallInvalidateRectWithNullNPPArgument.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h \
	Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h \
	Tools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/TestObject.h \
	Tools/DumpRenderTree/TestNetscapePlugIn/main.cpp \
	Tools/DumpRenderTree/TestNetscapePlugIn/unix/ForwardingHeaders/WebKit/npapi.h \
	Tools/DumpRenderTree/TestNetscapePlugIn/unix/ForwardingHeaders/WebKit/npfunctions.h \
	Tools/DumpRenderTree/TestNetscapePlugIn/unix/ForwardingHeaders/WebKit/npruntime.h

TestNetscapePlugin_libtestnetscapeplugin_la_LDFLAGS = \
	-rpath ${shell pwd}/$(top_builddir)/../unix/TestNetscapePlugin/.libs \
	$(no_undefined) \
	-avoid-version \
	-module

CLEANFILES += TestNetscapePlugin/libtestnetscapeplugin.la
endif

check-local:
	$(top_srcdir)/Tools/Scripts/run-gtk-tests --timeout=-1

EXTRA_DIST += \
	Tools/gtk/common.py \
	Tools/gtk/generate-feature-defines-files \
	Tools/gtk/generate-gtkdoc \
	Tools/gtk/gtkdoc.py \
	Tools/jhbuild/jhbuildutils.py \
	Tools/Scripts/VCSUtils.pm \
	Tools/Scripts/run-gtk-tests \
	Tools/Scripts/webkit-build-directory \
	Tools/Scripts/webkitdirs.pm

docs: docs-build.stamp
.PHONY : docs
DISTCLEANFILES += docs-build.stamp

docs_build_stamp_list = \
	Source/WebKit/gtk/docs/webkitenvironment.xml

if ENABLE_WEBKIT1
docs_build_stamp_list += \
	libwebkitgtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
	Source/WebKit/gtk/docs/webkitgtk-docs.sgml \
	Source/WebKit/gtk/docs/webkitgtk-sections.txt
endif

if ENABLE_WEBKIT2
docs_build_stamp_list += \
	libwebkit2gtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
	Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml \
	Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
endif

docs-build.stamp: $(docs_build_stamp_list)
	CC=$(CC) $(srcdir)/Tools/gtk/generate-gtkdoc
	@touch docs-build.stamp

clean-local: doc-clean-local
doc-clean-local:
	@rm -f Documentation/webkitgtk/*~ Documentation/webkitgtk*.bak
	@rm -f Documentation/webkit2gtk/*~ Documentation/webkit2gtk*.bak
distclean-local: doc-distclean-local
doc-distclean-local:
	@rm -rf Documentation
maintainer-clean-local: doc-maintainer-clean-local
doc-maintainer-clean-local: clean
	@rm -rf Documentation/webkitgtk Documentation/webkit2gtk
	-@rmdir Documentation

install-data-local:
if ENABLE_WEBKIT1
	@installfiles=`echo ./Documentation/webkitgtk/html/*`; \
	if test "$$installfiles" = './Documentation/webkitgtk/html/*'; \
	then echo 1>&2 'No documentation to install' ; \
	else \
	  DOC_MODULE_VERSION=`cat ./Documentation/webkitgtk/version.xml`; \
	  if test -n "$(DOC_MODULE_VERSION)"; then \
	    installdir="$(DESTDIR)$(HTML_DIR)/webkitgtk-$(DOC_MODULE_VERSION)"; \
	  else \
	    installdir="$(DESTDIR)$(HTML_DIR)/webkitgtk"; \
	  fi; \
	  $(mkinstalldirs) $${installdir} ; \
	  for i in $$installfiles; do \
	    echo ' $(INSTALL_DATA) '$$i ; \
	    $(INSTALL_DATA) $$i $${installdir}; \
	  done; \
	  if test -n "$(DOC_MODULE_VERSION)"; then \
	    mv -f $${installdir}/webkitgtk.devhelp2 \
	      $${installdir}/webkitgtk-$(DOC_MODULE_VERSION).devhelp2; \
	  fi; \
	fi
endif
if ENABLE_WEBKIT2
	@installfiles=`echo ./Documentation/webkit2gtk/html/*`; \
	if test "$$installfiles" = './Documentation/webkit2gtk/html/*'; \
	then echo 1>&2 'No documentation to install' ; \
	else \
	  DOC_MODULE_VERSION=`cat ./Documentation/webkit2gtk/version.xml`; \
	  if test -n "$(DOC_MODULE_VERSION)"; then \
	    installdir="$(DESTDIR)$(HTML_DIR)/webkit2gtk-$(DOC_MODULE_VERSION)"; \
	  else \
	    installdir="$(DESTDIR)$(HTML_DIR)/webkit2gtk"; \
	  fi; \
	  $(mkinstalldirs) $${installdir} ; \
	  for i in $$installfiles; do \
	    echo ' $(INSTALL_DATA) '$$i ; \
	    $(INSTALL_DATA) $$i $${installdir}; \
	  done; \
	  if test -n "$(DOC_MODULE_VERSION)"; then \
	    mv -f $${installdir}/webkit2gtk.devhelp2 \
	      $${installdir}/webkit2gtk-$(DOC_MODULE_VERSION).devhelp2; \
	  fi; \
	fi
endif
	@$(AM_V_GEN) PKG_CONFIG=$(PKG_CONFIG) $(PYTHON) $(srcdir)/Tools/gtk/generate-gtkdoc --rebase --virtual-root=$${DESTDIR}

uninstall-local:
if ENABLE_WEBKIT1
	@DOC_MODULE_VERSION=`cat ./Documentation/webkitgtk/version.xml`; \
	if test -n "$(DOC_MODULE_VERSION)"; then \
	  installdir="$(DESTDIR)$(HTML_DIR)/webkitgtk-$(DOC_MODULE_VERSION)"; \
	else \
	  installdir="$(DESTDIR)$(HTML_DIR)/webkitgtk"; \
	fi; \
	rm -rf $${installdir}
endif
if ENABLE_WEBKIT2
	@DOC_MODULE_VERSION=`cat ./Documentation/webkit2gtk/version.xml`; \
	if test -n "$(DOC_MODULE_VERSION)"; then \
	  installdir="$(DESTDIR)$(HTML_DIR)/webkit2gtk-$(DOC_MODULE_VERSION)"; \
	else \
	  installdir="$(DESTDIR)$(HTML_DIR)/webkit2gtk"; \
	fi; \
	rm -rf $${installdir}
endif

if ENABLE_GTK_DOC
noinst_DATA += docs-build.stamp
endif

